home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / ainet / t1vb432.frm (.txt) < prev    next >
Visual Basic Form  |  1997-07-11  |  11KB  |  241 lines

  1. VERSION 4.00
  2. Begin VB.Form frmMain 
  3.    Caption         =   "aiNet DLL & VB40 32 bit; Example #1"
  4.    ClientHeight    =   6324
  5.    ClientLeft      =   1068
  6.    ClientTop       =   1536
  7.    ClientWidth     =   9024
  8.    BeginProperty Font 
  9.       name            =   "MS Sans Serif"
  10.       charset         =   1
  11.       weight          =   700
  12.       size            =   7.8
  13.       underline       =   0   'False
  14.       italic          =   0   'False
  15.       strikethrough   =   0   'False
  16.    EndProperty
  17.    Height          =   6708
  18.    Icon            =   "T1VB432.frx":0000
  19.    Left            =   1020
  20.    LinkTopic       =   "Form1"
  21.    ScaleHeight     =   6324
  22.    ScaleWidth      =   9024
  23.    Top             =   1200
  24.    Width           =   9120
  25.    Begin VB.PictureBox Picture1 
  26.       BorderStyle     =   0  'None
  27.       Height          =   1452
  28.       Left            =   120
  29.       Picture         =   "T1VB432.frx":030A
  30.       ScaleHeight     =   1452
  31.       ScaleWidth      =   7692
  32.       TabIndex        =   3
  33.       Top             =   120
  34.       Width           =   7692
  35.    End
  36.    Begin VB.TextBox tOut 
  37.       BorderStyle     =   0  'None
  38.       BeginProperty Font 
  39.          name            =   "Courier New"
  40.          charset         =   1
  41.          weight          =   400
  42.          size            =   8.4
  43.          underline       =   0   'False
  44.          italic          =   0   'False
  45.          strikethrough   =   0   'False
  46.       EndProperty
  47.       Height          =   4572
  48.       Left            =   120
  49.       MultiLine       =   -1  'True
  50.       ReadOnly        =   -1  'True
  51.       TabIndex        =   2
  52.       Top             =   1680
  53.       Width           =   7332
  54.    End
  55.    Begin VB.CommandButton btnExit 
  56.       Caption         =   "E&xit"
  57.       Height          =   375
  58.       Left            =   7680
  59.       TabIndex        =   1
  60.       Top             =   2400
  61.       Width           =   1215
  62.    End
  63.    Begin VB.CommandButton btnStart 
  64.       Caption         =   "&Start"
  65.       Height          =   375
  66.       Left            =   7680
  67.       TabIndex        =   0
  68.       Top             =   1920
  69.       Width           =   1215
  70.    End
  71. Attribute VB_Name = "frmMain"
  72. Attribute VB_Creatable = False
  73. Attribute VB_Exposed = False
  74. Private Sub btnExit_Click()
  75.    End
  76. End Sub
  77. Private Sub btnStart_Click()
  78. '--------------------------------------------------------------------------'
  79. '                                                                          '
  80. '    (C) Copyright 1996 by:  aiNet                                         '
  81. '                            Trubarjeva 42                                 '
  82. '                            SI-3000 Celje                                 '
  83. '                            Europe, Slovenia                              '
  84. '     All Rights Reserved                                                  '
  85. '                                                                          '
  86. '     Subject: Visual Basic code for single vector prediction.             '
  87. '        File: T1VB432 - The XOR problem created by XOR.CSV file            '
  88. '       EMAIL: AINET@IKPIR.FAGG.UNI-LJ.SI                                  '
  89. '                                                                         '
  90. ' Last revision: October 17 1996                                          '
  91. '                                                                          '
  92. '--------------------------------------------------------------------------'
  93. '---------------------------------------------------------------------------
  94. '   Here it will be shown how we can colve the XOR problem using
  95. '   aiNet C functions
  96. '   The XOR problem:
  97. '   ================
  98. '      Number of model vectors: 4
  99. '          Number of variables: 3
  100. '    Number of input variables: 3
  101. '       Any discrete variables: NONE
  102. '      Model vectors:  Inp,Inp,Out
  103. '              row 1:  1,  1,  0
  104. '              row 2:  1,  0,  1
  105. '              row 3:  0,  1,  1
  106. '              row 4:  0,  0,  0
  107. '   Test vectors (vectors which will be used in prediction) together with
  108. '   penalty coefficient and penalty method.
  109. '       Prediction vectors:  Inp  Inp  Out
  110. '                    prd 1:  0.9  0.1  ??
  111. '                    prd 2:  0.1  0.9  ??
  112. '                    prd 3:  0.2  0.2  ??
  113. '                    prd 4:  0.7  0.7  ??
  114. '       Penalty coeffcient: 0.3
  115. '       Penalty methods: STATIC
  116. '   NOTE: Selected penalty coefficients are in no case optimal.
  117. '         They were selected randomly, to perform a few tests.
  118. '         The test results were compared with the results calculated by
  119. '         the main aiNet 1.22 application.
  120. '   ------------------------------------------------------------------------
  121. '   Results (rounded at fourth decimal):
  122. '   ------------------------------------------------------------------------
  123. '       Penalty cefficient: 0.3
  124. '       Penalty method:     STATIC
  125. '                                      (RESULT)
  126. '       Prediction vectors:  Inp  Inp  (  Out )
  127. '                    prd 1:  0.9  0.1  (1.0000)
  128. '                    prd 2:  0.1  0.9  (1.0000)
  129. '                    prd 3:  0.2  0.2  (0.0007)
  130. '                    prd 4:  0.7  0.7  (0.0096)
  131. '   ------------------------------------------------------------------------
  132. Dim i As Long
  133. Dim ret As Long                ' dummy for return values
  134.       
  135.    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  136.    ' Support for text output
  137.    Dim CRNL As String             ' Carriage return + newline
  138.    Dim T As String                ' tab
  139.    Dim TT As String               ' 2 x tab
  140.    CRNL = Chr(13) + Chr(10)
  141.    T = Chr(9)
  142.    TT = Chr(9) + Chr(9)
  143.    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  144.    ' Vectors to be predicted
  145.    ReDim predict(0 To 11) As Single
  146.    predict(0) = 0.9: predict(1) = 0.1: predict(2) = 999
  147.    predict(3) = 0.1: predict(4) = 0.9: predict(5) = 999
  148.    predict(6) = 0.2: predict(7) = 0.2: predict(8) = 999
  149.    predict(9) = 0.7: predict(10) = 0.7: predict(11) = 999
  150.    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  151.    ' Title
  152.    version = aiGetVersion()
  153.    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  154.    ' If you are in debug mode and you can not pass the line
  155.    ' above, copy ainet32.dll into Windows\System directory
  156.    major = Int(version / 100)
  157.    minor = version Mod 100
  158.    tOut = "aiNetDLL version " + CStr(major) + "." + CStr(minor)
  159.    tOut = tOut + " (C) Copyright by aiNet, 1996" + CRNL
  160.    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  161.    ' Register DLL
  162.    ret = aiRegistration("Your registration name", "Your code")
  163.    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  164.    ' Setup the model - read the csv file.
  165.    Dim model As Long    ' works like a pointer to aiModel structure
  166.    ' In some occasions next line produces en error because of an invalid
  167.    ' path. In this case edit this line and change the path to correct one
  168.    model = aiCreateModelFromCSVFile("c:\cpp\ainet\dll\vb4\32bit\xor.csv")
  169. '   model = aiCreateModelFromCSVFile("c:\ainet\dll\vb4\32bit\xor.csv")
  170.    If model = 0 Then
  171.       tOut = tOut + CRNL + "Error: Something went wrong during model creation!"
  172.       tOut = tOut + CRNL + "Please, see the source code - the file path is probably invalid!"
  173.       tOut = tOut + CRNL + "Specifying the correct path will put the problem away."
  174.       GoTo End_Sub
  175.    End If
  176.    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  177.    ' Output the model
  178.    nVec = aiGetNumberOfModelVectors(model)
  179.    nVar = aiGetNumberOfVariables(model)
  180.    ReDim flag(3) As Long
  181.    flag(1) = aiGetDiscreteFlag(model, 1)
  182.    flag(2) = aiGetDiscreteFlag(model, 2)
  183.    flag(3) = aiGetDiscreteFlag(model, 3)
  184.    tOut = tOut + CRNL + "             Model name: aiNet DLL test 1 (XOR.CSV)"
  185.    tOut = tOut + CRNL + "Number of model vectors: " + CStr(nVec)
  186.    tOut = tOut + CRNL + "    Number of variables: " + CStr(nVar)
  187.    tOut = tOut + CRNL + "         Variable names: A,   B,   A xor B"
  188.    tOut = tOut + CRNL + "          Discrete flag: "
  189.    tOut = tOut + CStr(flag(1)) + "    " + CStr(flag(2)) + "    " + CStr(flag(3))
  190.    ReDim var(3) As Single
  191.    Dim value As Single
  192.    For i = 1 To aiGetNumberOfModelVectors(model) Step 1
  193.       ret = aiGetVariableVB(mod